/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __AD9DF3EC_28B2_44C6_A3BF_2D6922A0F92A__
#define __AD9DF3EC_28B2_44C6_A3BF_2D6922A0F92A__

// DRIVER={MySQL ODBC 5.3 ANSI Driver};SERVER=192.168.80.131;PORT=3306;DATABASE=javadb;UID=root;PWD=root;CharSet=UTF8;

namespace xos_odbc
{

    /////////////////////////////////////////////////////////////////////////////////
    // 
    // 字段管理及绑定帮助功能接口
    // 
    class i_recordset : public xos::i_release
    {
    protected:
        virtual ~i_recordset(){}

    public:
        virtual int push( const char * lpszName, int32_t & data, bool bIsKey ) = 0;
        virtual int push( const char * lpszName, int64_t & data ) = 0;
        virtual int push( const char * lpszName, int16_t & data ) = 0;
        virtual int push( const char * lpszName, int8_t & data ) = 0;
        virtual int push( const char * lpszName, uint32_t & data, bool bIsKey ) = 0;
        virtual int push( const char * lpszName, uint64_t & data ) = 0;
        virtual int push( const char * lpszName, uint16_t & data ) = 0;
        virtual int push( const char * lpszName, uint8_t & data ) = 0;
        virtual int push( const char * lpszName, bool & data ) = 0;
        virtual int push( const char * lpszName, xos_box::i_string * lpData ) = 0;
        virtual int push( const char * lpszName, float & data, int nDigitNum ) = 0;
        virtual int push( const char * lpszName, double & data, int nDigitNum ) = 0;

        virtual const char * col_name( int nIndex, xos_box::i_string * lpData ) = 0;
        virtual int col_num() = 0;

        virtual int get( int nIndex, int32_t & data ) = 0;
        virtual int get( int nIndex, int64_t & data ) = 0;
        virtual int get( int nIndex, int16_t & data ) = 0;
        virtual int get( int nIndex, int8_t & data ) = 0;
        virtual int get( int nIndex, uint32_t & data ) = 0;
        virtual int get( int nIndex, uint64_t & data ) = 0;
        virtual int get( int nIndex, uint16_t & data ) = 0;
        virtual int get( int nIndex, uint8_t & data ) = 0;
        virtual int get( int nIndex, bool & data ) = 0;
        virtual int get( int nIndex, xos_box::i_string * lpData ) = 0;
        virtual int get( int nIndex, float & data ) = 0;
        virtual int get( int nIndex, double & data ) = 0;

        // 
        // 设置为更改过
        // 
        virtual int set_dirty( const char * lpszName ) = 0;
        // 
        // 设置为更改过
        // 
        virtual int set_dirty( int nIndex ) = 0;
        // 
        // 设置为改过
        // 
        virtual int set_all_dirty() = 0;
        // 
        // 恢复为没改过
        // 
        virtual int clear_dirty( const char * lpszName ) = 0;
        // 
        // 恢复为没改过
        // 
        virtual int clear_dirty( int nIndex ) = 0;
        // 
        // 恢复为没改过
        // 
        virtual int clear_all_dirty() = 0;

        // 
        // 设置表名
        // 
        virtual int set_table_name( const char * lpszTableName ) = 0;

        // 
        // 准备结果集句柄
        // 
        virtual int prepare_stmt() = 0;
        virtual int close_stmt() = 0;

        // 
        // 准备查询.
        // 
        // lpszSql说明：
        // 
        //  not null : where子句。如：where id = 1
        //      null : 全表查询
        // 
        virtual int compose_query( const char * lpszSql ) = 0;
        virtual int bind_query_col() = 0;

        // 
        // 准备修改
        // 
        virtual int compose_update() = 0;

        // 
        // 准备添加
        // 
        virtual int compose_add() = 0;

        // 
        // 准备删除
        // 
        virtual int compose_del() = 0;

        //
        // 编译sql
        // 
        //  0 : success. 
        //  1 : running. 
        // -1 : failed
        // 
        virtual int compile_sql() = 0;

        // 
        //  0 : success
        //  1 : pending
        //  2 : no data
        // -1 : failed
        // 
        virtual int execute_direct( const char * lpszSql ) = 0;
        virtual int execute() = 0;
        virtual int fetch() = 0;

        // 
        // 帮助方法
        // 
        virtual int set_id( int32_t id ) = 0;
        virtual const char * sql() = 0;
    };

} // xos_odbc

#endif // __AD9DF3EC_28B2_44C6_A3BF_2D6922A0F92A__
